Reading Correlation Data PRO
The Scripting app allows you to query correlated health data using the global Health.queryCorrelations() API. A correlation groups related health samples into a single logical event — such as a blood pressure reading (systolic and diastolic) or a food intake record (calories, protein, etc.).
This guide explains how to retrieve and interpret correlation data from HealthKit.
What Is a Correlation?
A correlation in HealthKit represents a composite health event made up of multiple samples, including:
"bloodPressure"— combinesbloodPressureSystolicandbloodPressureDiastolic"food"— may includedietaryEnergyConsumed,dietaryProtein,dietaryCarbohydrates, etc.
Each correlation includes:
- Start and end date
- Type (
"bloodPressure"or"food") - Metadata (optional)
- Associated samples (quantity or category samples)
API Overview
Parameters
Example: Query Blood Pressure Correlations
Example: Query Food Correlations
Accessing Correlation Samples
Each correlation contains the following sample arrays:
quantitySamples: All quantity samples (including cumulative/discrete)cumulativeQuantitySamples: Only cumulative quantity samplesdiscreteQuantitySamples: Only discrete quantity samplescategorySamples: Any associated category samples (for future support)
You can use .quantityType and .quantityValue(unit) to interpret each sample.
Error Handling
Summary
To read correlation data from HealthKit:
- Call
Health.queryCorrelations(type, options) - Iterate through each
HealthCorrelation - Access
quantitySamplesorcategorySamples - Use
.quantityValue(unit)to extract values
This is useful for composite health records like blood pressure or nutrition intake.
